<?php
require_once("func.php");

# http://localhost/TreeTasker-co/www/change.php?id=237&what=pri&direction=down

if(!empty($_GET['id']))
{
	if(!empty($_GET['what']))
	{
		if(!empty($_GET['direction']))
		{
			$id = $_GET['id'];
			$what = $_GET['what'];
			$direction = $_GET['direction'];
		
			$sql = "select ".$what." from todos where id = '".$id."'";
			echo $prio = dbq1($sql);
		
			if($direction === "down")
			{	// lowest prio = 10
				if($prio < 10)
				{
					$prio++;
				}
			}
			elseif($direction === "up")
			{	// highest prio = 1
				if($prio > 0)
				{
					$prio--;
				}
			}
		
#			echo $prio;
			
			$sql = "update todos set ".$what." = '".$prio."' where id='".$id."'";
			dbq($sql);
			header("Location: index.php?zoom_id=".$_GET['zoom_id']);
			exit();
		}
	}
}

?>